// pages/find/card/card-detail.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     * options.id == member_id
     */
    onLoad: function (options) {
        this.setData({
            imgSize: (app.window.width - 80) / 3,
            id: options.id
        })

    },
    onShow() {
        console.log(this.data)
        this.loadData();
    },
    /**
     * 
     */
    loadData: function () {
        app.http.get("member-visiting-card/card-info", {
            data: {
                id: this.data.id
            }
        }).then(res => {
            try {
                this.setData({
                    nickname: res.data.nickname,
                    images: res.data.images,
                    visiting_num: 0,
                    like_num: 0,
                    keep_num: 0,
                    detail: '暂无',
                    address: '',
                })
            } catch (err) {
                throw err
            }
        }).catch(err => {
            console.log(err)
            app.wxToast.error(err.message)
        })
    },

    keep(evt) {
        wx.showLoading({
            title: '加载中...',
        })
        app.http.get("member-visiting-card/add-keep", {
            data: { id: this.data.id }
        }).then(res => {
            wx.hideLoading()
            this.onLoad()
        }).catch(err => {
            app.wxToast.error(err.message)
        })
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
    }
})